﻿@using Weibo4Sharp.Model

@{
    ViewBag.Title = "Detail";
    ViewBag.Scripts = new List<string> { "repost.js" };

    var weibo = (WeiboStatus)ViewBag.Weibo;
    var reposts = (IEnumerable<WeiboStatus>)ViewBag.Reposts;
    var repostStatus = string.Empty;
    
    if(weibo.RetweetedStatus != null)
    {
        repostStatus = "//@" + weibo.User.ScreenName + ":" + weibo.Text;
    }
}

@Html.Partial("_Weibo", weibo, new ViewDataDictionary() { {"isDetail", true }} )

<h3>Repost</h3>

@using (Ajax.BeginForm("Create", "Repost", new AjaxOptions {
    HttpMethod = "POST",
    UpdateTargetId = "reposts",
    InsertionMode = InsertionMode.InsertBefore,
    OnBegin = "onRepostBegin",
    OnSuccess = "onRepostSuccess",
    OnFailure = "onRepostFailure"
}))
{
    <div id="repost-container">
        <textarea id="repost-area" name="status">@repostStatus</textarea>        
        <div class="mt8">
            <input class="bb" id="submit-button" type="submit" value="Repost" />            
            <input type="hidden" name="id" value="@weibo.Id" />            
        </div>
    </div>    
}

<div id="reposts">
@foreach (var repost in reposts)
{
    @Html.Partial("_Weibo", repost, 
        new ViewDataDictionary() { { "hideRepost", true }, {"isDetail", true } });
}
</div>

